Source for file SC_Fpdf.php
Documentation is available at SC_Fpdf.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/*----------------------------------------------------------------------
*----------------------------------------------------------------------
require (DATA_REALDIR . 'module/fpdf/fpdf.php');
require (DATA_REALDIR . 'module/fpdi/japanese.php');
define('PDF_TEMPLATE_REALDIR', TEMPLATE_ADMIN_REALDIR . 'pdf/');
function SC_Fpdf($download, $title, $tpl_pdf = 'nouhinsyo1.pdf') {
$this->pdf_download = $download; // PDFのダウンロード形式(0:表示、1:ダウンロード)
$this->tpl_title = $title;
$this->tpl_dispmode = 'real'; // 表示モード
$masterData = new SC_DB_MasterData_Ex();
$this->arrPref = $masterData->getMasterData('mtb_pref');
$this->width_cell = array(110.3,12,21.7,24.5);
$this->label_cell[] = $this->lfConvSjis("商品名 / 商品コード / [ 規格 ]");
$this->label_cell[] = $this->lfConvSjis("金額(税込)");
$this->arrMessage = array(
'このたびはお買上げいただきありがとうございます。',
$this->pdf = new PDF_Japanese();
$this->pdf->AddSJISFont();
$this->pdf->SetFont('SJIS');
$this->pdf->AliasNbPages();
$this->pdf->SetMargins(15, 20);
$pageno = $this->pdf->setSourceFile($this->tpl_pdf);
$this->arrData = $arrData;
$tplidx = $this->pdf->ImportPage(1);
$this->pdf->SetDisplayMode($this->tpl_dispmode);
if (SC_Utils_Ex::sfIsInt($arrData['order_id'])) {
$order_id = $arrData['order_id'];
// テンプレート内容の位置、幅を調整 ※useTemplateに引数を与えなければ100%表示がデフォルト
$this->pdf->useTemplate($tplidx);
$objDb = new SC_Helper_DB_Ex();
$arrInfo = $objDb->sfGetBasisData();
$this->lfText(125, 60, $arrInfo['shop_name'], 8, 'B'); //ショップ名
$this->lfText(125, 63, $arrInfo['law_url'], 8); //URL
$this->lfText(125, 68, $arrInfo['law_company'], 8); //会社名
$text = "〒 ". $arrInfo['law_zip01']. " - ". $arrInfo['law_zip02'];
$this->lfText(125, 71, $text, 8); //郵便番号
$text = $this->arrPref[$arrInfo['law_pref']]. $arrInfo['law_addr01'];
$this->lfText(125, 74, $text, 8); //都道府県+住所1
$this->lfText(125, 77, $arrInfo['law_addr02'], 8); //住所2
$text = "TEL: ". $arrInfo['law_tel01']. "-". $arrInfo['law_tel02']. "-". $arrInfo['law_tel03'];
if (strlen($arrInfo['law_fax01']) > 0) {
$text .= " FAX: ". $arrInfo['law_fax01']. "-". $arrInfo['law_fax02']. "-". $arrInfo['law_fax03'];
$this->lfText(125, 80, $text, 8); //TEL・FAX
if ( strlen($arrInfo['law_email']) > 0 ) {
$text = "Email: ". $arrInfo['law_email'];
$this->lfText(125, 83, $text, 8); //Email
$this->pdf->Image($logo_file, 124, 46, 40);
$this->lfText(27, 70, $this->arrData['msg1'], 8); //メッセージ1
$this->lfText(27, 74, $this->arrData['msg2'], 8); //メッセージ2
$this->lfText(27, 78, $this->arrData['msg3'], 8); //メッセージ3
$text = "作成日: ". $this->arrData['year']. "年". $this->arrData['month']. "月". $this->arrData['day']. "日";
$this->lfText(158, 288, $text, 8); //作成日
$text = "〒 ". $this->arrDisp['order_zip01']. " - ". $this->arrDisp['order_zip02'];
$this->lfText(23, 43, $text, 10); //購入者郵便番号
$text = $this->arrPref[$this->arrDisp['order_pref']] . $this->arrDisp['order_addr01'];
$this->lfText(27, 47, $text, 10); //購入者都道府県+住所1
$this->lfText(27, 51, $this->arrDisp['order_addr02'], 10); //購入者住所2
$text = $this->arrDisp['order_name01']. " ". $this->arrDisp['order_name02']. " 様";
$this->lfText(27, 59, $text, 11); //購入者氏名
$this->pdf->SetFontSize(10);
$this->lfText(25, 125, SC_Utils_Ex::sfDispDBDate($this->arrDisp['create_date']), 10); //ご注文日
$this->lfText(25, 135, $this->arrDisp['order_id'], 10); //注文番号
$this->pdf->SetFont('', 'B', 15);
$this->pdf->Cell(0, 10, $this->lfConvSjis($this->tpl_title), 0, 2, 'C', 0, ''); //文書タイトル(納品書・請求書)
$this->pdf->Cell(0, 66, '', 0, 2, 'R', 0, '');
$this->pdf->Cell(5, 0, '', 0, 0, 'R', 0, '');
$this->pdf->Cell(0, 45, '', 0, 2, '', 0, '');
$this->pdf->SetFontSize(8);
for ($i = 0; $i < count($this->arrDisp['quantity']); $i++ ) {
$data[0] = $this->arrDisp['quantity'][$i];
$data[1] = SC_Helper_DB_Ex::sfCalcIncTax($this->arrDisp['price'][$i]);
$data[2] = $data[0] * $data[1];
$arrOrder[$i][0] = $this->lfConvSjis($this->arrDisp['product_name'][$i]. " / ");
$arrOrder[$i][0] .= $this->lfConvSjis($this->arrDisp['product_code'][$i]. " / ");
if ($this->arrDisp['classcategory_name1'][$i]) {
$arrOrder[$i][0] .= $this->lfConvSjis(" [ ". $this->arrDisp['classcategory_name1'][$i]);
if ($this->arrDisp['classcategory_name2'][$i] == "") {
$arrOrder[$i][0] .= " ]";
$arrOrder[$i][0] .= $this->lfConvSjis(" * ". $this->arrDisp['classcategory_name2'][$i]. " ]");
$arrOrder[$i][3] = number_format($this->arrDisp['subtotal']). $monetary_unit;
$arrOrder[$i][3] = number_format($this->arrDisp['deliv_fee']). $monetary_unit;
$arrOrder[$i][3] = number_format($this->arrDisp['charge']). $monetary_unit;
$arrOrder[$i][3] = "- ". number_format(($this->arrDisp['use_point'] * POINT_VALUE) + $this->arrDisp['discount']). $monetary_unit;
$arrOrder[$i][3] = number_format($this->arrDisp['payment_total']). $monetary_unit;
if ($this->arrData['disp_point'] && $this->arrDisp['customer_id']) {
$arrOrder[$i][3] = number_format($this->arrDisp['use_point']). $point_unit;
$arrOrder[$i][3] = number_format($this->arrDisp['add_point']). $point_unit;
$this->pdf->FancyTable($this->label_cell, $arrOrder, $this->width_cell);
$this->pdf->Cell(0, 10, '', 0, 1, 'C', 0, '');
$this->pdf->SetFontSize(9);
$this->pdf->MultiCell(0, 6, $this->lfConvSjis("< 備 考 >"), 'T', 2, 'L', 0, ''); //備考
$this->pdf->SetFontSize(8);
$this->pdf->MultiCell(0, 4, $this->lfConvSjis($this->arrData['etc1']. "\n". $this->arrData['etc2']. "\n". $this->arrData['etc3']), '', 2, 'L', 0, ''); //備考
if ($this->pdf_download == 1) {
if ($this->pdf->PageNo() == 1) {
$filename = "nouhinsyo-No". $this->arrData['order_id']. ".pdf";
$filename = "nouhinsyo.pdf";
$this->pdf->Output($this->lfConvSjis($filename), 'D');
// PDF_Japanese::Text へのパーサー
function lfText($x, $y, $text, $size = 0, $style = '') {
$bak_font_style = $this->pdf->FontStyle;
$bak_font_size = $this->pdf->FontSizePt;
$this->pdf->SetFont('', $style, $size);
$this->pdf->Text($x, $y, $this->lfConvSjis($text));
$this->pdf->SetFont('', $bak_font_style, $bak_font_size);
if(SC_Utils_Ex::sfIsInt($order_id)) {
$objQuery = new SC_Query_Ex();
$arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
$this->arrDisp = $arrRet[0];
list ($point) = SC_Helper_Customer_Ex::sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
$this->arrDisp['point'] = $point;
$arrRet = SC_Utils_Ex::sfSwapArray($arrRet);
if($this->arrDisp["memo02"] != "") $this->arrDisp["payment_info"] = unserialize($this->arrDisp["memo02"]);
$this->arrDisp["payment_type"] = "お支払い";
$objQuery = new SC_Query_Ex();
$col = "product_id, product_class_id, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
$objQuery->setOrder("order_detail_id");
$arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
// 文字コードSJIS変換 -> japanese.phpで使用出来る文字コードはSJIS-winのみ
return mb_convert_encoding($conv_str, "SJIS-win", CHAR_CODE);
Documentation generated on Fri, 24 Feb 2012 14:02:34 +0900 by Seasoft
|